class Course < ActiveRecord::Base
  has_many :courses_sessions
  
  def self.get_all
    find(:all, :conditions => ['active = ? ', true])
  end
  
  
  def self.get_by_id(id)
    find(id, :conditions => ['active = ?', true])
  end
  
  
  def self.delete(id)
    conn = connection
    i = conn.update("UPDATE courses SET active = false WHERE id = #{id}")
    conn.commit_db_transaction
    return i == 1
  end
end
